//
//  XLPlayerError.m
//  FFMpegKitDemo
//
//  Created by ilongge on 2023/8/2.
//

#import "XLPlayerError.h"

#define errorDomain @"error.XLPlayer.ilongge"

@implementation XLPlayerError
+(NSError *)errorWithCode:(XLPlayerErrorCode)errorCode
{
    NSError *error = nil;
    switch (errorCode) {
        case XLPlayerErrorCodeUrlNil:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"Url Can't Be Nil"}];
        }
            break;
        case XLPlayerErrorCodeItemNil:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"Item Can't Be Nil"}];
        }
            break;
        case XLPlayerErrorCodeAssetNil:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"Asset Can't Be Nil"}];
        }
            break;
        case XLPlayerErrorCodeUrlInvalid:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"Url Can't Be Invalid"}];
        }
            break;
        case XLPlayerErrorCodeCreateFormatContextFailed:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"formatContext Create Failed"}];
        }
            break;
        case XLPlayerErrorCodeFormatContextNull:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"formatContext Can't Be Null"}];
        }
            break;
        case XLPlayerErrorCodeCreateVideoCodecFailed:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"VideoCodec Create Failed"}];
        }
            break;
        case XLPlayerErrorCodeCreateAudioCodecFailed:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"AudioCodec Create Failed"}];
        }
            break;
        case XLPlayerErrorCodeFileInvalid:
        {
            error = [NSError errorWithDomain:errorDomain
                                        code:-errorCode
                                    userInfo:@{NSLocalizedDescriptionKey:@"File Can't Be Invalid"}];
        }
            break;
        default:
            break;
    }
    
    
    
    return error;
}
@end
